package nc.ui.arap.buttonstat;

import nc.ui.arap.engine.AbstractRuntime;
import nc.ui.arap.engine.ExtButtonObject;
import nc.ui.arap.engine.IActionRuntime;
import nc.ui.arap.engine.IButtonStatus;
import nc.ui.arap.global.DjTempletHelper;
import nc.ui.ep.dj.ArapBillWorkPageConst;
import nc.vo.ep.dj.DJZBHeaderVO;
import nc.vo.ep.dj.DJZBItemVO;
import nc.vo.ep.dj.DJZBVO;
import nc.vo.ep.dj.DJZBVOConsts;

public class DjSsRowUnCloseLinsener implements IButtonStatus {

	public void updateButtonStatus(ExtButtonObject bo, IActionRuntime runtime) {
		// TODO Auto-generated method stub
		if(!(runtime instanceof AbstractRuntime))
			return ;
		AbstractRuntime runt=(AbstractRuntime)runtime;
		bo.setEnabled(false);
		if(runt.getCurrWorkPage()==ArapBillWorkPageConst.LISTPAGE){
			DJZBItemVO item = DjTempletHelper.getListSelectedItem(runt);
			if (item != null) {
				if (item.getCloser() != null
						&&item.getCloser().trim().length() > 0) {
						bo.setEnabled(true);
						bo.setVisible(true);
				} 
			}
		}else{
			DJZBVO djvo = runt.getDjDataBuffer().getCurrentDJZBVO();
			if (djvo != null) {
				DJZBHeaderVO head = (DJZBHeaderVO) djvo.getParentVO();
				if (head != null) {
					DJZBItemVO item =DjTempletHelper. getCardSelectedItems(runt);
					if (item != null) {
						if (item.getCloser() != null
								&& item.getCloser().trim().length() > 0) {
							bo.setEnabled(true);
							bo.setVisible(true);
						}
					}

				}
			}
		}
	}

}
